Skip to content

Conversation

@fogelito
Copy link
Contributor

@fogelito fogelito commented Nov 20, 2025

Summary by CodeRabbit

  • New Features

    • Added support for database joins (inner, left, and right joins) enabling queries across related collections.
    • Introduced context-aware query processing for improved permission and relationship handling.
  • Refactor

    • Restructured query API to use context-driven parameters, affecting how selections and filters are specified.
    • Redesigned database adapter interface signatures for more flexible query parameter composition.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Database/Database.php (1)

1-1: Fix PSR-12 indentation failure flagged by Pint.

The linter reports a PSR-12 statement indentation error in this file (Line 1). Please run Pint or adjust indentation to satisfy PSR-12.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/e2e/Adapter/Scopes/JoinsTests.php`:
- Around line 34-35: The PHPDoc `@var` annotations incorrectly name the variable
`$database` while the actual variable is `$db`; update each docblock to read
`@var Database $db` so PHPStan recognizes the correct variable type—apply this
change to the docblock immediately above the `$db = $this->getDatabase();`
assignment and the other occurrences that reference `$database` in the same test
class (replace `@var Database $database` with `@var Database $db`).

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/Database/Query.php (2)

1271-1288: ⚠️ Potential issue | 🔴 Critical

Copy-paste bug: wrong fallback variables for $offset and $cursor

Line 1277: $offset = $values[0] ?? $limit; — should fall back to $offset, not $limit.
Line 1286: $cursor = $values[0] ?? $limit; — should fall back to $cursor, not $limit.

If $values[0] is not set, offset and cursor will be incorrectly set to the limit value instead of preserving their current state.

Proposed fix
-                    $offset = $values[0] ?? $limit;
+                    $offset = $values[0] ?? $offset;
-                    $cursor = $values[0] ?? $limit;
+                    $cursor = $values[0] ?? $cursor;

79-127: ⚠️ Potential issue | 🟡 Minor

TYPES array is missing join and relation-equal constants

isMethod() (lines 454–457) recognizes TYPE_RELATION_EQUAL, TYPE_INNER_JOIN, TYPE_LEFT_JOIN, and TYPE_RIGHT_JOIN, but the public TYPES array (lines 79–127) does not include them. While the codebase uses specialized type arrays (JOINS_TYPES, FILTER_TYPES, etc.) for actual validation rather than the general TYPES array, the inconsistency creates confusion about the completeness of TYPES and could introduce bugs if future code relies on it for validation.

Add the missing constants to TYPES for consistency:

Proposed fix
         self::TYPE_OR,
         self::TYPE_ELEM_MATCH,
-        self::TYPE_REGEX
+        self::TYPE_REGEX,
+        self::TYPE_RELATION_EQUAL,
+        self::TYPE_INNER_JOIN,
+        self::TYPE_LEFT_JOIN,
+        self::TYPE_RIGHT_JOIN,
     ];
🤖 Fix all issues with AI agents
In `@src/Database/Query.php`:
- Line 195: The Query class declares a protected bool $system (set in the
constructor and passed from the select() factory) but never exposes it, making
it dead state; add a public accessor (e.g., isSystem() : bool or getSystem() :
bool) near the other accessors in Query so callers can read the flag, and ensure
its name matches the project's boolean getter convention and is used where
select() supplies the value.
🧹 Nitpick comments (1)
src/Database/Query.php (1)

350-378: Inconsistent exception type — use QueryException instead of \Exception

getCursorDirection() and getOrderDirection() throw \Exception, while the rest of the class uses QueryException. This makes it harder for callers to catch query-related errors uniformly.

Proposed fix
-        throw new \Exception('Invalid method: Get cursor direction on "'.$this->method.'" Query');
+        throw new QueryException('Invalid method: Get cursor direction on "'.$this->method.'" Query');
-        throw new \Exception('Invalid method: Get order direction on "'.$this->method.'" Query');
+        throw new QueryException('Invalid method: Get order direction on "'.$this->method.'" Query');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants